var express = require('express');
var router = express.Router();
var sqlQuery = require('../../module/sql');

router.get('/',async(req,res)=>{
    let Nav = await getNav();
    let id = req.query.id
    let sqlStr1 = 'SELECT film.id,film.filmName,film.`year`,film.brief,film.director,film.region,film.movieUrl,film.poster,type.typeName FROM film,type WHERE film.Typeid = type.id and film.id = ?'
    let result1 = await sqlQuery(sqlStr1,[id])
    let options = {Nav,result1}
    console.log(result1)
    res.render('home/movie',options)
})


//获取导航
async function getNav(){
    let sqlStr = 'select * from nav where state = 1'
    let result = await sqlQuery(sqlStr);
        //结果返回
    return Array.from(result);
  }



module.exports = router;